home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
vol_100
/
193_01
/
deff3.txt
< prev
next >
Wrap
Text File
|
1985-11-13
|
13KB
|
402 lines
DEFF3.TXT
---------
I have given, below, a description of each of the functions
which I have written for the file -
DEFF3.C
and which may be accessed through -
DEFF3(.CRL)
when you use the CLINK function with BDS C. It is not
necessary to specify "DEFF3" on the command line as BDS C
will look for any missing functions in the DEFF files,
automatically, in answer to a RETURN entered when it asks
you for instructions as to which CRL files it should search
for the missing functions.
If you intend to use DEFF3 in this way then it should be on
the same disk as the BDS C DEFF files. Now, the functions
I have written and what they do are -
BITCOUNT(n)
unsigned n;
----------
Returns the number of set bits ( = 1) in a byte.
BINARY(x, v, n)
int x, v[], n;
---------------
Checks whether a binary number (x) occurs in a sorted array
(v, of n elements) and, if so, returns the binary number or
else returns -1 if it doesn't occur.
CGET()
------
Similar to "getchar" in what it does except that it will
read ANY byte value from the console. i.e. the value you
enter doesn't have to be either ASCII or printable.
It returns the value of the byte entry.
CLOSE_FILE(fcb)
char fcb[36];
---------------
This will close the file whose name is included in the file
control block pointed to by "fcb". It is the companion
function to "OPEN_FILE" and should be used to close any file
previously opened with OPEN_FILE. It returns the same
values as OPEN_FILE.
CLRSCREEN()
-----------
Will clear the screen and home the cursor, using in-built
terminal software commands. It is (probably) only usable
by Hazeltine family terminals but could be altered to suit
other terminals provided you know the byte value(s) to send
to the terminal to activate the clear screen/home function.
Doesn't return anything.
CON_STAT()
----------
This checks the console status and returns ZERO if there is
no character waiting, else it returns 0xff....NOT the
character itself. It is a useful function for those inputs
where you tell the user -
"Enter any character to continue."
CPUT(c)
int c;
-------
Similar to "putchar" except that it will send ANY byte value
to the console. Naturally the console will only display
the "visible" characters. Doesn't return anything useful.
CREATE_FILE(fcb)
char fcb[36];
----------------
This will create the file named in the file control block
(see open_file for a description of this) an initialise it
for both read and write functions. Note particularly that
it doesn't check to see whether a file of this name already
exists so you need to do this independently if you want to
make sure you haven't got two files of the same name in the
disk directory.
It is supposed to return 0xff (255 decimal) if the disk is
full and the name can't be created, but I'm not so sure
that you can rely on it to do so. Probably the best way
to be sure is to now try to open the file (with open_file)
and see what happens then.
DIRECTC(duty)
int duty;
-------------
This is CP/M function No. 6 and it can be used to either get
a character from the terminal, or to send a character to the
console. It depends on the value of "duty" which should be
either -
0xff for input from the terminal
or the byte value for output to the console
It returns the input character in the first case or zero in
the second case.
ERASE_FILE(fcb)
char fcb[36];
---------------
Erases from the directory the name of the file in the file
control block. For a description of this see open_file.
It will return 0xff if the file isn't found.
GET_CPM()
---------
Returns a 16-bit number (in HL) with the details -
H = 0x00 for CP/M OR H = 0x01 for MP/M
L = 0x00 for all releases prior to 2.0
L = 0x20 for version 2.0, 0x21 for version 2.1, 0x22
for version 2.2, and so on.
If you want to use any of this information then you will
need to mask off H (or L) to find out what it was the
function returned.
GET_DEFAULT()
-------------
Returns the name for the current default disk. Note A = 0,
B = 1....and so on.
GET_IOBYTE()
------------
Returns the current IOBYTE setting under CP/M 2.2.
INDEX(s, t)
char s[], t[];
-------------
Returns a pointer to the position of string "t" inside
string "s", else returns -1 if no match is found.
ITOA(n, str)
int n;
char s[];
------------
Will convert an integer (n) into a printable ASCII string,
which is placed in "str". This is one of the obvious
functions which should already have been included in BDS C.
ISALNUM(c)
char c;
----------
Returns TRUE/FALSE whether the character is alpha-numeric.
MAKE_RO()
---------
Makes the current logical disk read-only status. I don't
think it returns anything.
OPEN_FILE(fcb)
char fcb[36];
--------------
Opens the nominated file, the name of which must be in the
file control block ("fcb") in the manner required by CP/M.
Note that the file is opened for BOTH reading and writing.
Before using this function you should have already made a
file control block with the function -
setfcb(fcb, filename)
Note particularly "fcb" as used in these functions is a
pointer to the file control block or, as used in assembly
language programming, it is the address of the fcb which
holds the file name. This should be an external buffer so
that it is known to all functions in the programme.
This will return 0xff if the open was unsuccessful or a
number 0, 1, 2 or 3 (which is an offset into the DMA buffer)
if the open succeeded. For those who understand the way
CP/M works, this offset may be used to get the directory
entry information on the opened file.
To be able to access the DMA buffer you must have first
created a DMA buffer whose address (the pointer to) is
known to you. Do this with the function -
set_dma(dma)
int dma[128];
PRINT_DEC(n)
int n;
------------
Prints a decimal number (n) to the console.
PRT_STR(str)
char *str;
------------
Prints a string (terminated by the character "$") to the
console. Doesn't return anything.
Note you shouldn't use this function if you expect to meet
with the dollar sign other than as the end of line marker.
READ_SEQ_SEC(fcb)
char fcb[36];
-----------------
Starting from the first available sector (of 128 bytes) it
will reach each successive sector in t